//
//  ProfileEditViewController.swift
//  App_Profile
//
//  Created by 蒋晨成 on 2022/1/18.
//

import Adaptor
import App_Common
import RxCocoa
import RxSwift
import SnapKit
import Toast
import UICore
import UIKit

class ProfileEditViewController: ViewController {
    lazy var contentView: ProfileEditContentView = {
        let contentView = ProfileEditContentView()
        contentView.backgroundColor = Adaptor.Profile.background
        return contentView
    }()

    lazy var imagePicker: ImagePicker = {
        let imagePicker = ImagePicker(presentationController: self, delegate: self)
        return imagePicker
    }()

    lazy var viewModel = ProfileEditViewModel()
    lazy var disposeBag = DisposeBag()
}

// MARK: - Override

extension ProfileEditViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        setupNav()
        setup()
        bind()
    }
}

private extension ProfileEditViewController {
    func setupNav() {
        if (navigationController?.viewControllers.count ?? 0) > 1 {
            let backImage = ProfileModular.image(named: "Common.Nav.Action.Back")
            addDefaultLeftBarButtonItem(image: backImage)
        }
        setNavigationBarTintColor(tintColor: Adaptor.Profile.titleColor)
    }

    func setup() {
        view.backgroundColor = Adaptor.Profile.background
        contentView.x.add(to: view).snp.makeConstraints {
            $0.top.equalTo(view.safeAreaLayoutGuide.snp.top)
            $0.trailing.leading.bottom.equalToSuperview()
        }
    }
}

// MARK: - Routable

extension ProfileEditViewController: Routable {
    static func initialize(values _: [String: Any]) -> ViewController? {
        ProfileEditViewController(nibName: nil, bundle: nil)
    }

    static var routePattern = "profile/edit"

    static let description: String = "Profile Edit Router"
}
